package com.xiaomazi.edu.controller;

import com.xiaomazi.common.utils.R;
import com.xiaomazi.edu.dto.CourseInfoDTO;
import com.xiaomazi.edu.dto.CourseQuery;
import com.xiaomazi.edu.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: llxy-parent
 * @description: 课程前端控制器
 * @author: 小马子
 * @create: 2023-02-15 15:54
 **/
@RestController
@RequestMapping("/eduservice/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @PostMapping("/addCourseInfo")
    public R addCourseInfo(@RequestBody CourseInfoDTO courseInfoDTO){
        return courseService.addCourseInfo(courseInfoDTO);
    }

    @PostMapping("/uploadCourseInfo")
    public R uploadCourseInfo(@RequestBody CourseInfoDTO courseInfoDTO){
        return courseService.uploadCourseInfo(courseInfoDTO);
    }

    @GetMapping("/courseInfo/{courseId}")
    public R courseInfo(@PathVariable String courseId){
        return courseService.courseInfo(courseId);
    }

    @GetMapping("/getPublishCourseInfo/{id}")
    public R getPublishCourseInfo(@PathVariable String id){
        return courseService.publishCourseInfo(id);
    }
    @PostMapping("/publishCourse/{id}")
    public R publishCourse(@PathVariable String id){
        return courseService.updateStatusById(id);
    }

    @DeleteMapping("/removeCourse/{id}")
    public R removeCourse(@PathVariable String id){
        return courseService.removeCourseById(id);
    }

    @PostMapping("/pageCourseCondition")
    public R pageCourseCondition(@RequestBody CourseQuery courseQuery){
        return courseService.pageCourseCondition(courseQuery);
    }
}
